//
//  ParkHistoryViewController.m
//  PeopleStreet
//
//  Created by 刘建峰 on 16/7/8.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "ParkHistoryViewController.h"
#import "ParkHistoryTableViewCell.h"

static NSString * cellIndentfier = @"ParkHistoryTableViewCell";


@interface ParkHistoryViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UIView *navView;
@property (weak, nonatomic) IBOutlet UIView *typeView;
@property (weak, nonatomic) IBOutlet UIButton *parkHisButton;
@property (weak, nonatomic) IBOutlet UIButton *dateHisButton;
@property (weak, nonatomic) IBOutlet UIButton *chargeHisButton;
@property (weak, nonatomic) IBOutlet UITableView *tableView;


@end

@implementation ParkHistoryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViewLayout];
    // Do any additional setup after loading the view.
}


- (void)initViewLayout{
    
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navView];
    [self adaptiveViewLayout:self.typeView];
    
    [self.tableView registerNib:[UINib nibWithNibName:cellIndentfier bundle:nil] forCellReuseIdentifier:cellIndentfier];
    
    _tableView.dataSource = self;
    _tableView.delegate = self;
}

- (IBAction)back:(id)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}


- (IBAction)changeTypeHandel:(UIButton *)sender {
    sender.selected = YES;
    if (sender == _parkHisButton) {
        _dateHisButton.selected = NO;
        _chargeHisButton.selected = NO;
    }else if (sender == _dateHisButton){
        _parkHisButton.selected = NO;
        _chargeHisButton.selected = NO;
    }else if (sender == _chargeHisButton){
        _parkHisButton.selected = NO;
        _dateHisButton.selected = NO;
    }
    [_tableView reloadData];
}


#pragma mark -- UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (_chargeHisButton.selected) {
        return 114*VerticalRatio();
    }else{
        return 114*VerticalRatio();
    }
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (_parkHisButton.selected||_dateHisButton.selected) {
        ParkHistoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentfier];
        if (cell == nil) {
            cell= [[ParkHistoryTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentfier];
        }
        
        if (_dateHisButton.selected) {
            cell.cancleImage.hidden = NO;
        }else{
            cell.cancleImage.hidden = YES;
        }
        
//        NSDictionary * dic = _listArray[indexPath.row];
//        
//        cell.superTitle.text  = [NSString stringWithFormat:@"%@",dic[@"mmdeName"]];
//        cell.superDetail.text  = [NSString stringWithFormat:@"%@",dic[@"mmdeContent"]];
//        cell.time.text = [ NSString stringWithFormat:@"%@",dic[@"mmdeCreateTime"]];
//        if ([NSString stringWithFormat:@"%@",dic[@"mmdeCreateTime"] ].length>0) {
//            cell.time.text = [Common updateTimeForData:[NSString stringWithFormat:@"%@",dic[@"mmdeCreateTime"] ]];
//        }
//        
        return cell;
    }else{
        ParkHistoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndentfier];
        if (cell == nil) {
            cell= [[ParkHistoryTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndentfier];
        }
//        NSDictionary * dic = _listArray[indexPath.row];
//        
//        NSString * image = [NSString stringWithFormat:@"%@",dic[@"mmsuImageUrl"]];
//        if (image.length>0) {
//            [cell.farmImage sd_setImageWithURL:[NSURL URLWithString:image]];
//        }
//        cell.farmTitle.text  = [NSString stringWithFormat:@"%@",dic[@"mmsuName"]];
//        cell.farmDetail.text  = [NSString stringWithFormat:@"%@",dic[@"mmsuContent"]];
//        if ([NSString stringWithFormat:@"%@",dic[@"mmsuCreateTime"] ].length>0) {
//            cell.time.text = [Common updateTimeForData:[NSString stringWithFormat:@"%@",dic[@"mmsuCreateTime"] ]];
//        }
        return cell;
    }
    
    return nil;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
